<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    var arr = [6,8,5,7,9,4,1,2,3];
    for (var i = 0;i <= arr.length - 1;i++){
        for (var o = 0;o <= arr.length - i - 1;o++){
            if (arr[o] > arr[o+1]){
                var temp = arr[o];
                arr[o] = arr[o+1];
                arr[o+1] = temp;
            }
        }
    }
    console.log(arr);
</script>
<body>

</body>
</html>